
// pop弹窗
var showPopWindow = function (text, fn) {
    fn = fn || function (){};
    var single = getSingle(createPop);
    var pop = single(text, function (){
        fn();
        pop.hide();
    }, function (){
        pop.hide();
    });
    pop.show();
}
var getSingle = function (fn){
    var pop = null;
    return function (){
        return pop || (pop = fn.apply(this, arguments));
    }
};
var createPop = function (text, confirm, cancel){
    text = text || "";
    confirm = confirm || function (){};
    cancel = cancel || function (){};
    var arr = [
        '<div class="pop-window">',
            '<div class="pop-content">',
                '<div class="text">',
                    '<b>' + text + '</b>',
                '</div>',
                '<div class="button">',
                    '<button class="confirm">确定</button>',
                    '<button class="cancel">取消</button>',
                '</div>',
            '</div>',
        '</div>'
    ];

    var pop = $(arr.join(""));
    pop.appendTo($(document.body));

    pop.find("button.confirm").click(function (){
        confirm();
    });
    pop.find("button.cancel").click(function (){
        cancel();
    });

    return pop;
};
